package com.smartcampus.demo.repository;

import com.smartcampus.demo.domain.Temperature;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TemperatureDao extends JpaRepository<Temperature, Long> {

    // 查询最新的 n 个数据
    @Query(value = "SELECT * FROM temperature ORDER BY time DESC LIMIT ?1", nativeQuery = true)
    List<Temperature> findTopNByOrderByCreatedAtDesc(int n);
}
